Ext.define('PJ.view.workmanagement.Frame', {
    extend: 'Ext.container.Container',
    layout: 'border',
    requires: ['PJ.view.workmanagement.List', 'PJ.view.workmanagement.Tree'],
    items: [{
        region: 'center',
        xtype: 'workmanagementList'
    }, {
        region: 'west',
        width: 225,
        xtype: "workmanagementTree",
        collapsible: true,
        listeners: {
        	// 叶子节点点击事件,如果非叶子节点与此动作相同，需覆盖itemclick事件
        	itemClick: function(view, record, htmlelement, index, eventObject, object){
        		var gridPanel = this.up("container").down("workmanagementList");
        		gridPanel.searchCategoryIndex = record.raw.id;
        		gridPanel.treeNode = record;
        		// 设置grid翻页工具条生效
        		gridPanel.isPossibleLoad = true;
        		var store = gridPanel.getStore();
        		var newParams = {
        				searchTreePath: record.raw.id
        		};
        		// grid加载生效
        		gridPanel.store.isLoad = true;
        		// 重置翻页属性
        		gridPanel.resetPage();
        		// 4.0强制更改store参数写法
        		var params = store.proxy.extraParams;
        		Ext.apply(params, newParams);
        		store.load();
        	},
        	//显示树的一级菜单
        	load: function(treeStore, node, records, successful, eOpts){
        		//避免在第一个子节点循环展开；有子节点才展开
        		if (this.searchNodeType == 0 && records != null&&node.hasChildNodes()) {
        			this.fireEvent("itemclick",this.view,records[0],$(this.view.getEl().dom).find(".x-grid-row:first")[0]); //点击展开节点
        		}
        	}
        }
    }],
    listeners: {
    	beforerender: function(){
			//加载树
			var tree = this.down("workmanagementTree");
            var treeStore = tree.getStore();
            treeStore.setProxy({
                type:gj_onlineLearning_constant.loadType,
                url: treeStore.url
            });
            tree.getStore().load();
        }
    }
});